/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Utility;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;





/**
 *
 * @author KINNAN
 */
public class VarcharUpdater {
    
    public static VarcharUpdater getInstance() {
        
        return new VarcharUpdater();
    }
    
    public String getValue(String varCharValue){
        char FirstLetterChar = varCharValue.charAt(0);
        String FirstLetter = String.valueOf(FirstLetterChar);
        String intLeft = "";
        
        intLeft = this.removeFirstCharater(varCharValue);
        Integer pKey = Integer.parseInt(intLeft);
        pKey++;
        intLeft = (String)pKey.toString();
        intLeft = FirstLetter + intLeft;
        
        return intLeft;
    }

    private String removeFirstCharater(String varCharValue) {
        
        return varCharValue.substring(1);
    }
    
    public String getTheLastPK(List<String> list) {
        int greatest=0;
        char prefix=list.get(0).toString().charAt(0);
        String largest_no_string="";
        Iterator it=list.iterator();
        while(it.hasNext()) {
            String pk=this.removeFirstCharater((String)it.next());
           
            int g=Integer.parseInt(pk);
           
            if(g>greatest) {
                greatest=g;
               
                largest_no_string=pk;
               
            }
            
        }
        return prefix+largest_no_string;
    }
    
    public List<String> getPKList(List list,int index) {
      return null;
    }
    public static void main(String[] args) {
        VarcharUpdater v=new VarcharUpdater();
        List<String> l=new ArrayList<String>();
        l.add("R0");
        l.add("R21");
        l.add("R10");
        l.add("R3");
        
        System.out.println(v.getTheLastPK(l));
    }
}
